from random import random


def int_input(tips):
    return int(input(tips))


def get_rand():
    return int(random() * 100)


def guess(ran_num, input_num):
    tip = "你猜的数"
    if ran_num > input_num:
        print(tip + "小了")
        return False
    elif ran_num < input_num:
        print(tip + "大了")
        return False
    else:
        print("恭喜猜中")
        return True


def v3_main():
    ran_num = int(random() * 100)
    input_num = int_input("请输入猜的数：")

    coin_count = 5000

    while coin_count > 500:
        while True:
            if guess(ran_num, input_num):
                print("幸运数字为：", input_num)
                break
            coin_count -= 500
            print("扣500金币，金币余额：", coin_count)
            if coin_count < 500:
                print("本金不足了")
                return
            input_num = int_input("请重新输入:")
        coin_count += 3000
        print("金币余额：", coin_count)
        is_continue = input("是否继续下一轮游戏 ? (y/n)：")
        if is_continue == 'n':
            return
        ran_num = int(random() * 100)
        input_num = int_input("请输入猜的数：")


def v2_main():
    ran_num = int(random() * 100)
    input_num = int_input("请输入猜的数：")

    coin_count = 5000

    while coin_count > 500:
        while True:
            if guess(ran_num, input_num):
                print("幸运数字为：", input_num)
                break
            coin_count -= 500
            print("扣500金币，金币余额：", coin_count)
            if coin_count < 500:
                print("本金不足了")
                return
            input_num = int_input("请重新输入:")
        coin_count += 3000
        print("金币余额：", coin_count)
        ran_num = int(random() * 100)
        input_num = int_input("请输入猜的数：")


def v1_main():
    ran_num = int(random() * 100)
    input_num = int_input("请输入猜的数：")

    while ran_num != input_num:
        tip = "你猜的数"
        if ran_num > input_num:
            tip += "小了"
        elif ran_num < input_num:
            tip += "大了"
        input_num = int_input(tip + '，请重新输入：')

    print("恭喜猜中，本轮幸运数字：", input_num)
